const appModel = require('../models/appModel');
const create = async (ctx, next) => {
  const req = ctx.request.body;
  const data = Object.assign({}, req);
  const result = await appModel.create(data);
  if (result) {
    ctx.body = {
      code: 1,
      msg: '添加成功！',
      data: {}
    };
  }
}

const update = async (data) => {
  const app = await find();
  await appModel.updateOne({
    _id: app._id,
  }, data);
}

const find = async () => {
  const result = await appModel.find();
  return result[0];
}

module.exports = {
  create,
  update,
  find
};